import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Drohne here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Drohne extends Gegner
{
    int v; // Momentangeschwindigkeit in x-Richtung
    int w; // Momentangeschwindigkeit in y-Richtung
    int a; // Beschleunigung in y-Richtung

    public Drohne(int l)
    {
        super(l);
        super.hp = l*40;
        super.speed = 4;
        v = super.speed;
        w = 1;
        a = 1;
    }

    /**
     * Act - do whatever the Gegner wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        //if(Greenfoot.getRandomNumber(10)<1) v = -v;
        super.act();
        if(getX() > 1024 || getX() < 0) return;
        if(v > 0) setImage("Drohne_Links.png");
        else setImage("Drohne_Rechts.png");
        if(Greenfoot.getRandomNumber(100)<5) a = -a;
        if(w >= 2 || w <= -2) a = -a;
        w = w + a;
        schießen();
        bewegen();
    }    

    public void schießen()
    {
        if(Greenfoot.getRandomNumber(1000)<3) super.schießen(false, 2, 25, "bomb.png");
    }

    public void bewegen()
    {
        if(getX() < 10 || getX() > 990) 
        {
            v = -v;
            //setLocation(getX() + v, getY() + w);
        }
        if(getY()+w <= 50 || getY()+w >= 300) 
        {
            w = 0;
            //setLocation(getX() + v, getY());
        }
        setLocation(getX() + v, getY() + w);
    }

}
